package xyz.yuzegod.megawalls.classes.normal.arcane;

import org.bukkit.Material;
import org.bukkit.event.block.BlockBreakEvent;
import xyz.yuzegod.megawalls.classes.Classes;
import xyz.yuzegod.megawalls.classes.CollectSkill;
import xyz.yuzegod.megawalls.event.PlayerEnergyChangeEvent;
import xyz.yuzegod.megawalls.game.GamePlayer;
import xyz.yuzegod.megawalls.stats.KitStatsContainer;
import xyz.yuzegod.megawalls.util.ItemUtils;

import java.util.ArrayList;
import java.util.List;

public class FourthSkill extends CollectSkill
{
    public FourthSkill(final Classes classes) {
        super("奥术采矿", classes);
    }
    
    @Override
    public int maxedLevel() {
        return 3;
    }
    
    @Override
    public double getAttribute(final int level) {
        switch (level) {
            case 1: {
                return 16.0;
            }
            case 2: {
                return 18.0;
            }
            case 3: {
                return 20.0;
            }
            default: {
                return 16.0;
            }
        }
    }
    
    @Override
    public List<String> getInfo(final int level) {
        final List<String> lore = new ArrayList<String>();
        if (level == 1) {
            lore.add(" §8▪ §7挖掘矿石会给你§a" + this.getAttribute(level) + "§7能量。");
            return lore;
        }
        lore.add(" §8▪ §7挖掘矿石会给你§8" + this.getAttribute(level - 1) + " ➜ §a" + this.getAttribute(level) + "§7能量。");
        return lore;
    }
    
    @Override
    public void upgrade(final GamePlayer gamePlayer) {
        final KitStatsContainer kitStats = gamePlayer.getPlayerStats().getKitStats(this.getClasses());
        kitStats.addSkill4Level();
    }
    
    @Override
    public int getPlayerLevel(final GamePlayer gamePlayer) {
        return gamePlayer.getPlayerStats().getKitStats(this.getClasses()).getSkill4Level();
    }
    
    @Override
    public void onBlockBreak(final KitStatsContainer kitStats, final BlockBreakEvent e) {
        if (ItemUtils.matchMaterial(e.getBlock(),Material.COAL_ORE,Material.IRON_ORE,Material.GOLD_ORE,Material.DIAMOND_ORE)) {
            final GamePlayer gamePlayer = GamePlayer.get(e.getPlayer().getUniqueId());
            gamePlayer.addEnergy((int)this.getAttribute(this.getPlayerLevel(gamePlayer)), PlayerEnergyChangeEvent.ChangeReason.MAGIC);
        }
    }
}
